function handImg(mid) {
  if (!mid)
    return "https://img1.baidu.com/it/u=4112794715,1317791462&fm=253&fmt=auto&app=138&f=JPEG?w=690&h=340";
  return `http://y.gtimg.cn/music/photo_new/T001R800x800M000${mid}.jpg`;
}

export const handImgUrl = handImg;

export const handSingerList = (list) => {
  if (!(list && Array.isArray(list))) return [];
  // console.log(list);
  let obj = {};
  list.map((item) => {
    const { Findex, Fsinger_mid, Fsinger_name } = item;
    const singerPic = handImg(Fsinger_mid);
    if (obj[Findex]) {
      obj[Findex].push({ Findex, Fsinger_mid, Fsinger_name, singerPic });
    } else {
      obj[Findex] = [{ Findex, Fsinger_mid, Fsinger_name, singerPic }];
    }

    return item;
  });
  // console.log(obj);
  // 将对象变成数组
  let arr = [];
  for (const key in obj) {
    if (key != 9) {
      arr.push({
        Fidx: key,
        singers: obj[key],
      });
    }
  }
  let sortArr = arr.sort((a, b) => a.Fidx.charCodeAt() - b.Fidx.charCodeAt());
  return sortArr;
};
